/**
 * Company : SIANGKLOM.
 * Created By : Chatree Siangklom
 * Created On : Nov 14, 2013  2:27:01 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.interfaces.commons
 * File Name : XmlResultback.java
 * TODO
 */
package com.tis.interfaces.commons;


import java.io.Serializable;
import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import promis.utility.CommonService;
import promis.utility.Utilitys;

/**
 * @author Chatree Siangklom of Administrator
 * Date =Oct 24, 2013 : 11:20:03 AM 
 * CreateBy=Chatree Siangklom
 * 
 * XmlResultback
 * TODO
 */
@XmlRootElement(name="ResultBack")
@SuppressWarnings("serial")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlResultback  implements Serializable {
	
	/**
	 * 
	 * Date =Oct 24, 2013 : 11:23:56 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java long 
	 * serialVersionUID
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	
	@XmlElement(name="code") String msgcode;
	@XmlElement(name="description") String msgDescription;	
	@XmlElement(name="sapno") String extRefNo;
	@XmlElement(name="sapkey") String extRefKey;
	
	@XmlAttribute
	@XmlElement(name="instanceno") String instanceNo;
	@XmlElement(name="module") String module;	
	private Date returnDateTime;
	/**
	 * @return the msgcode
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java String
	 * TODO
	 */
	public String getMsgcode() {
		return msgcode;
	}
	/**
	 * @param msgcode the msgcode to set
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java String
	 * TODO
	 */
	public void setMsgcode(String msgcode) {
		this.msgcode = msgcode;
	}
	/**
	 * @return the msgDescription
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java String
	 * TODO
	 */
	public String getMsgDescription() {
		return msgDescription;
	}
	/**
	 * @param msgDescription the msgDescription to set
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java String
	 * TODO
	 */
	public void setMsgDescription(String msgDescription) {
		this.msgDescription = msgDescription;
	}
	/**
	 * @return the extRefNo
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java String
	 * TODO
	 */
	public String getExtRefNo() {
		return extRefNo;
	}
	/**
	 * @param extRefNo the extRefNo to set
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java String
	 * TODO
	 */
	public void setExtRefNo(String extRefNo) {
		this.extRefNo = extRefNo;
	}
	/**
	 * @return the extRefKey
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java String
	 * TODO
	 */
	public String getExtRefKey() {
		return extRefKey;
	}
	/**
	 * @param extRefKey the extRefKey to set
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java String
	 * TODO
	 */
	public void setExtRefKey(String extRefKey) {
		this.extRefKey = extRefKey;
	}
	/**
	 * @return the instanceNo
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java String
	 * TODO
	 */
	public String getInstanceNo() {
		return instanceNo;
	}
	/**
	 * @param instanceNo the instanceNo to set
	 * Date =Oct 24, 2013 : 11:23:42 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java String
	 * TODO
	 */
	public void setInstanceNo(String instanceNo) {
		this.instanceNo = instanceNo;
	}
	/**
	 * @return the returnDateTime
	 * Date =Oct 24, 2013 : 11:27:57 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java Date
	 * TODO
	 */
	@XmlElement(name="returnon", type=String.class)
	public String getReturnDateTimeToString() {
		return CommonService.ConvertDateTimeToStringDisplay(this.returnDateTime);
	}
	
	/**
	 * @return the returnDateTime
	 * Date =Oct 24, 2013 : 11:30:43 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java Date
	 * TODO
	 */
	public Date getReturnDateTime() {
		return this.returnDateTime;
	}
	/**
	 * @param returnDateTime the returnDateTime to set
	 * Date =Oct 24, 2013 : 11:27:57 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java Date
	 * TODO
	 */
	public void setReturnDateTime(Date returnDateTime) {
		this.returnDateTime = returnDateTime;
	}
	/**
	 * @return the module
	 * Date =Oct 24, 2013 : 11:32:21 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback.java String
	 * TODO
	 */
	public String getModule() {
		return module;
	}
	/**
	 * @param module the module to set
	 * Date =Oct 24, 2013 : 11:32:21 AM 
	 * CreateBy=Chatree Siangklom
	 *  XmlResultback.java String
	 * TODO
	 */
	public void setModule(String module) {
		this.module = module;
	}
	
	/**
	 * Date =Oct 24, 2013 : 11:33:51 AM 
	 * CreateBy=Chatree Siangklom
	 * XmlResultback
	 * TODO
	 * @param module
	 * @param msgcode
	 * @param msgDescription
	 * @param extRefNo
	 * @param extRefKey
	 * @param instanceNo
	 * @param returnDateTime
	 */
	public XmlResultback(String module, String msgcode, String msgDescription,
			String extRefNo, String extRefKey, String instanceNo,
			Date returnDateTime) {
		this.module = module;
		this.msgcode = msgcode;
		this.msgDescription = msgDescription;
		this.extRefNo = extRefNo;
		this.extRefKey = extRefKey;
		this.instanceNo = instanceNo;
		this.returnDateTime = returnDateTime;
	}
	
	public XmlResultback(String module){
		this.module = module;
	}
	
	public XmlResultback(String module, String instanceNo){
		this.module = module;
		this.instanceNo = instanceNo;
	}
	
	public XmlResultback(String module, String instanceNo, Date returnDateTime){
		this.module = module;
		this.instanceNo = instanceNo;
		this.returnDateTime = returnDateTime;
	}
	
	public String GennerateToXml() {
		StringBuilder temp = new StringBuilder();
		try{
			temp.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
			temp.append("<SapResultBack>");
			temp.append("<module>").append(this.module).append("</module>");
			temp.append("<msgcode>").append(this.msgcode).append("</msgcode>");
			temp.append("<msgDescription>").append(this.msgDescription).append("</msgDescription>");
			temp.append("<extRefNo>").append(this.extRefNo).append("</extRefNo>");
			temp.append("<extRefKey>").append(this.extRefKey).append("</extRefKey>");
			temp.append("<instanceNo>").append(this.instanceNo).append("</instanceNo>");
			temp.append("<returnDateTime>").append(this.getReturnDateTimeToString()).append("</returnDateTime>");
			temp.append("</SapResultBack>");
		}catch(Exception e){
			e.printStackTrace();
		}
		return temp.toString();
	}

}